<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="url" method="get">
    <span>用户名：</span>
    <input type="text" name="username" id="username"><br>

    <span>性别：</span>
    <input type="radio" name="sex" value="man" id="man">男
    <input type="radio" name="sex" value="woman" id="woman">女 <br>
    <input type="submit" value="submit">
</form>
<script>
    var input_text = document.getElementById("username");

    //单选框作判断的情况下，可以设置为
    var man = document.getElementById("man");
    var woman = document.getElementById("woman");

    var test=function (){
        if(man.checked||woman.checked) {
            if (man.checked) {
                alert("sex is man")
            } else {
                alert("sex is woman")
            }
        }
        else
        {
            alert("sex is not chosen!")
        }
    }
</script>
</body>
</html>